<template>
  <div class="header">
    <div class="background">
      <img :src="seller.avatar">
    </div>
    <div class="seller-info">
      <div class="avatar-wrapper">
        <img :src="seller.avatar" width="64" height="64">
      </div>
      <div class="info-wrapper">
        <div class="title">
          <span class="icon"></span>
          <span class="text">{{seller.name}}</span>
        </div>
        <div class="delivery">
          <span class="desc">{{seller.description}}</span>
          <span class="tiem">/ {{seller.deliveryTime}}分钟送达</span>
        </div>
        <div  v-if="seller.supports" class="supports">
          <span class="icon" :class="classMap[seller.supports[0].type]"></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div  v-if="seller.supports" @click="showDetailFunc" class="count-wrapper">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div @click="showDetailFunc" class="bulletin" >
      <div class="bulletin-wrapper">
        <span class="icon"></span><span class="text">{{seller.bulletin}}</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <transition name="fade">
      <div v-show="showDetailFlag" class="detail">
        <div class="detail-wrapper">
          <div class="name-wrapper">{{seller.name}}</div>
          <div class="star-wrapper">
            <star :size="size" :score="seller.score"></star>
          </div>
          <div class="info-wrapper">
            <span class="line"></span>
            <span class="info">优惠信息</span>
            <span class="line"></span>
          </div>
          <div v-if="seller.supports" class="discount-wrapper">
            <ul>
              <li class="discount-main" v-for="item in seller.supports">
                <span class="icon" :class="classMap[item.type]"></span><span class="text">{{item.description}}</span>
              </li>
            </ul>
          </div>
          <div class="info-wrapper">
            <span class="line"></span>
            <span class="info">商家公告</span>
            <span class="line"></span>
          </div>
          <div class="bulletin-wrapper">
            <p>{{seller.bulletin}}</p>
          </div>
        </div>
        <div class="close-wrapper">
          <i @click="closeDetailFunc" class="icon-close"></i>
        </div>
      </div>
    </transition>
  </div>
</template>

<script type="text/ecmascript-6">
  import star from '../star/star.vue'

  export default{
    name:'header',
    props:{
      seller:{
        type:Object
      }
    },
    data() {
      return{
        showDetailFlag: false,
        size:48,
        classMap: ['decrease','discount','special','invoice','guarantee']
      }
    },
    methods:{
      showDetailFunc() {
        this.showDetailFlag = true;
      },
      closeDetailFunc(){
        this.showDetailFlag = false;
      }
    },
    components:{
      star
    }

  }

</script>

<style rel="stylesheet/scss" lang="scss">
 @import '../../common/mixin.scss';
 @import "../../common/icon.css";

  .header{
    width: 100%;
    height: 134px;
    position: relative;
    background: rgba(7,17,27,0.5);
    overflow: hidden;
    .seller-info{
      position: relative;
      padding: 24px 12px 18px 24px;
      color: rgb(255,255,255);
      font-size: 0;
      .avatar-wrapper{
        display: inline-block;
      }
      .info-wrapper{
        position: relative;
        display: inline-block;
        margin-left: 16px;
        vertical-align: top;
        .title{
          margin: 2px 0 8px 0;
          .icon{
            display: inline-block;
            width: 30px;
            height: 18px;
            background-size: 30px 18px;
            @include  bg_image('brand');
          }
          .text{
            margin-left: 6px;
            vertical-align: top;
            font-size: 16px;
            line-height: 18px;
            font-weight: bold;
          }
        }
        .delivery{
          font-size: 12px;
          line-height: 12px;
          font-weight: 200;
          margin-bottom: 10px;
        }
        .supports{
          margin-bottom: 2px;
          .icon{
            display: inline-block;
            width: 12px;
            height: 12px;
            background-size: 12px 12px;
          }
          .icon.decrease{
            @include bg_image('decrease_1');
          }
          .icon.discount{
            @include bg_image('discount_1');
          }
          .icon.guarantee{
            @include bg_image('guarantee_1');
          }
          .icon.invoice{
            @include bg_image('invoice_1');
          }
          .icon.special{
            @include bg_image('special_1');
          }
          .text{
            vertical-align: top;
            font-size: 10px;
            line-height: 12px;
            font-weight: 200;
            margin-left: 4px;
          }
        }

      }
      .count-wrapper{
        position: absolute;
        right: 12px;
        bottom: 14px;
        height: 24px;
        padding: 5px 8px 5px 10px;
        border-radius: 14px;
        background-color: rgba(0,0,0, 0.2);
        box-sizing: border-box;
        .count{
          font-size: 10px;
          font-weight: 200;
          line-height: 12px;
          vertical-align: top;
        }
        .icon-keyboard_arrow_right{
          display: inline-block;
          font-size: 10px;
          line-height: 12px;
          margin-left: 2px;
        }
      }

    }
    .bulletin{
      position: relative;
      height: 28px;
      width: 100%;
      background: rgba(7,17,27,0.2);
      color: #ffffff;

      .bulletin-wrapper{
        height: 100%;
        width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        box-sizing: border-box;
        padding-right: 28px ;
        .icon{
          display: inline-block;
          width: 22px;
          height: 12px;
          background-size: 22px 12px;
          @include  bg_image('bulletin');
          vertical-align: top;
          margin: 8px 4px 0 12px;
        }
        .text{
          font-weight: 200;
          font-size: 10px;
          line-height: 28px;
        }
        .icon-keyboard_arrow_right{
          display: inline-block;
          position: absolute;
          right: 12px;
          top: 8px;
          font-size: 10px;
          /*margin: 4px;*/
        }
      }

    }
    .background{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -1;
      filter: blur(10px);
      img{
        width: 100%;
        height: 100%;
      }

    }
    .detail{
      position: fixed;
      top:0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(7,17,27,0.8);
      color: #ffffff;
      overflow: auto;
      z-index: 200;
      .detail-wrapper{
        width: 100%;
        min-height: 100%;
        padding: 64px 36px 80px;
        box-sizing: border-box;
        .name-wrapper{
          font-size: 16px;
          line-height: 16px;
          text-align: center;
          font-weight: 700;
        }
        .star-wrapper{
          padding: 16px 0 28px;
          text-align: center;
        }
        .info-wrapper{
          display: flex;
          .info{
            font-size: 15px;
            padding: 0 12px;
            font-weight: 700;
          }
          .line{
            flex: 1;
            position: relative;
            top: -6px;
            border-bottom:1px solid rgba(255,255,255,0.2);
          }
        }
        .discount-wrapper{
          padding: 24px 12px 28px;
          .discount-main{
            margin-bottom: 12px;
            &:last-child{
              margin-bottom: 0;
            }
          }
          .icon{
            display: inline-block;
            width: 16px;
            height: 16px;
            background-size: 16px 16px;
          }
          .icon.decrease{
            @include bg_image('decrease_2');
          }
          .icon.discount{
            @include bg_image('discount_2');
          }
          .icon.guarantee{
            @include bg_image('guarantee_2');
          }
          .icon.invoice{
            @include bg_image('invoice_2');
          }
          .icon.special{
            @include bg_image('special_2');
          }
          .text{
            font-size: 13px;
            font-weight: 200;
            line-height: 16px ;
            vertical-align: top;
            margin-left: 6px;
          }
        }
        .bulletin-wrapper{
          font-size: 12px;
          font-weight: 200;
          line-height: 24px;
          padding: 24px 12px 0;
        }
      }
      .close-wrapper{
        width: 32px;
        height: 32px;
        font-size: 32px;
        margin: -64px auto 0 auto;
      }
    }

  }


</style>
